package realdance.swing.jdbc;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;

import java.awt.Font;

import javax.swing.JTextField;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class SungJuk extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField eng;
	private JTextField mat;
	private JTextField name;
	private JTextField kor;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SungJuk frame = new SungJuk();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SungJuk() {
		
		DefaultTableModel dfmodel = new DefaultTableModel(){
			public boolean isCellEditable(int row, int column) {	
			return false;	
			}
			
		};
	
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel Naminglbl = new JLabel("성적처리 프로그램");
		Naminglbl.setFont(new Font("굴림", Font.PLAIN, 24));
		Naminglbl.setBounds(272, 58, 242, 37);
		contentPane.add(Naminglbl);
		
		JLabel korlbl = new JLabel("국어");
		korlbl.setBounds(261, 207, 57, 15);
		contentPane.add(korlbl);
		
		JLabel englbl = new JLabel("영어");
		englbl.setBounds(261, 265, 57, 15);
		contentPane.add(englbl);
		
		JLabel matlbl = new JLabel("수학");
		matlbl.setBounds(261, 323, 57, 15);
		contentPane.add(matlbl);
		
		eng = new JTextField();
		eng.setBounds(398, 262, 116, 21);
		contentPane.add(eng);
		eng.setColumns(10);
		
		mat = new JTextField();
		mat.setBounds(398, 320, 116, 21);
		contentPane.add(mat);
		mat.setColumns(10);
		
		JButton btn1 = new JButton("입력 완료");
		btn1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String msg = name.getText()+"/" + kor.getText() +
						"/" + eng.getText() + "/" + mat.getText();
				
				
				J26_SungJukVO sj= new J26_SungJukVO();
				sj.setName(name.getText());
				sj.setKor(kor.getText());
				sj.setEng(eng.getText());
				sj.setMat(mat.getText());
				
				new J26_SungJukService().createSungJuk(sj);
				
				msg += "\n" + sj.getTot() + "/" + sj.getAvg() + "/" + sj.getGrd();
				JOptionPane.showMessageDialog(null, msg);
			}
		});
		btn1.setBounds(272, 451, 97, 23);
		contentPane.add(btn1);
		
		JButton btn2 = new JButton("다시 입력");
		btn2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			name.setText("");
			kor.setText("");
			eng.setText("");
			mat.setText("");

				
			}
		});
		btn2.setBounds(420, 451, 97, 23);
		contentPane.add(btn2);
		
		JLabel namelbl = new JLabel("이름");
		namelbl.setBounds(261, 159, 57, 15);
		contentPane.add(namelbl);
		
		name = new JTextField();
		name.setBounds(398, 156, 116, 21);
		contentPane.add(name);
		name.setColumns(10);
		
		kor = new JTextField();
		kor.setBounds(398, 204, 116, 21);
		contentPane.add(kor);
		kor.setColumns(10);
		
	
}
}